# -*- coding: utf-8 -*-
# created by Src - 一路好时光
import requests

# 假设您已经获取了以下必要的信息
access_token = "8e45ab6d713fc3296f8da8f928e5f415"
friend_uid = "1482551165"
message_content = "您好，这是一条测试消息"

url = f'https://api.vc.bilibili.com/web_im/v1/web_im/send_msg?access_token={access_token}&uid={friend_uid}&msg={message_content}'

headers = {
    "Content-Type": "application/x-www-form-urlencoded"
}

try:
    response = requests.post(url, headers=headers)
    if response.status_code == 200:
        print("消息发送成功")
    else:
        print(f"消息发送失败，状态码: {response.status_code}")
except requests.exceptions.RequestException as e:
    print(f"请求发送时发生异常: {e}")